﻿using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            using (var reader = ImageReader.Create(textBox1.Text))
            using (var resize = new Resize(480, 640, ResizeInterpolationMode.High))
            {
                //using (var unsharpMask = new UnsharpMask(0.35f, 1, 0))
                using (var writer = ImageWriter.Create(FileFormat.Jpeg, $@"{ Application.StartupPath }\{ Guid.NewGuid().ToString().ToUpper()}.jpg"))
                {
                    //Pipeline.Run(reader + resize + unsharpMask + writer);
                    Pipeline.Run(reader + resize + writer);
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            //openFileDialog.InitialDirectory = "d:\\";//should be attention to the path is "d:\\" not "d:\"
            openFileDialog.Filter = "Face picture|*.jpg|All documents|*.*";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog.FileName;
            }
       
        }
    }
}
